package com.stx.config;

import com.stx.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
//全局异常处理
@RestControllerAdvice
@Slf4j
public class GlobalExceptionAdvice {
    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler({Exception.class})
    public Result allException(Exception e) {
        e.printStackTrace();
        log.error(e.getMessage());
        return Result.error(e.getMessage());
    }
}
